import xlrd
from sklearn import datasets


def read03Excel(path):
    workbook = xlrd.open_workbook(path)
    sheets = workbook.sheet_names()
    worksheet = workbook.sheet_by_name(sheets[0])
    all_items = []
    for i in range(0, worksheet.nrows):
        sub_items = []
        for j in range(0, worksheet.ncols):
            sub_items.append(worksheet.cell_value(i, j))
        all_items.append(sub_items)
    return all_items


import numpy as np
from sklearn import preprocessing
from sklearn import svm, metrics

path = 'bank.xls'
data = read03Excel(path)
target = []
cols = []
for row in data:
    target.append(row[0])
    cols.append(row[1:])
# Y = np.asarray(target)
# X = np.asarray(cols)
Y = target
X = preprocessing.scale(cols)
n = round(len(X)*.9)
#clf = svm.SVC(C=1.2, kernel='linear', gamma=0.4)
clf = eval('svm.SVC()')
clf.fit(X[:n], Y[:n])
expected = Y[n:]
predicted = clf.predict(X[n:])
print("Classification report for classifier %s:\n%s\n"
      % (clf, metrics.classification_report(expected, predicted)))
print("Confusion matrix:\n%s" %
      metrics.confusion_matrix(expected, predicted))
